关于
Http中的options方法被称为预请求,是用于在通信过程中获得具有Request-uri标识资源的方法。
用途
- 获取服务器支持的Http请求方法。
- 检查服务器性能。(CORS)
触发条件
- 请求方法不是Get/head/post。
- Post方法手动设置Content-Type的值不是
application/x-www-form-urlencoded、multipart/form-data、text/plain。 - 设置了自定义的请求头。(不包括
Accept、Accept-Language、Content-Type、Viewport-width等常用字段)